home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_27786.txt < prev    next >
Text File  |  1991-02-27  |  817b  |  24 lines

  1. -- card: 27786 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10. UNIONS
  11.  
  12. The syntax for defining and using unions is identical to that for structs.
  13.  
  14.     union    input_value
  15.     {
  16.         int    i;
  17.         float    f;
  18.     };
  19.  
  20. Unlike a struct, however, declaring a variable of this type allocates space for only the LARGEST member in the union.  When a value is assigned to one of the members, any value formerly associated with another member is lost; that is, only one member contains a value at a time.  This property is useful when the programmer would like to define a variable which can take on values of different types at different points in  his/her program.
  21.  
  22. -- part contents for background part 7
  23. ----- text -----
  24. 71